package com.antgroup.seckill.business.goods.service.impl;

import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author wangxy
 * @date 2024/8/4 16:48
 */
@Service
public class TestRedissonService {

    @Autowired
    private RedissonClient redissonClient;

    public void someMethod() {
        RLock lock = redissonClient.getLock("myLock");
        try {
            lock.lock();
            // 执行需要锁保护的代码
        } finally {
            lock.unlock();
        }
    }
}
